﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ShopPowerTemplate.Common
{
    class ExceptionsHelper
    {
        public static async void ShowFatalError(string message, UICommand command)
        {
            MessageDialog dialog = new MessageDialog(message, "Error");

            if(command != null)
                dialog.Commands.Add(command);

            await dialog.ShowAsync();
        }

        public static void ShowError(Exception ex, TextBlock errorMessageTextBlock, Button saveButton = null, Button deleteButton = null)
        {
            errorMessageTextBlock.Text = "Error: " + ex.Message;
            errorMessageTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;

            if(saveButton != null)
                saveButton.IsEnabled = true;

            if(deleteButton != null)
                deleteButton.IsEnabled = true;
        }
    }
}
